cmake_minimum_required(VERSION 3.8)

project(libsweety VERSION 3.0.0 DESCRIPTION "libsweety")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)

if(MSVC)
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
	add_definitions(-D_SW_EXPORT_)
endif()

# 设置include路径
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/src/app)
include_directories(${CMAKE_SOURCE_DIR}/src/components)
include_directories(${CMAKE_SOURCE_DIR}/src/framework)
include_directories(${CMAKE_SOURCE_DIR}/src/backends)
include_directories(${CMAKE_SOURCE_DIR}/src/misc)
include_directories(${CMAKE_SOURCE_DIR}/src/tools)
include_directories(${CMAKE_SOURCE_DIR}/third-party)
include_directories(${CMAKE_SOURCE_DIR}/third-party/opencv/include)

#设置连接库路径
if(CMAKE_CL_64)
    link_directories(${CMAKE_SOURCE_DIR}/third-party/glfw/lib/x64)
else(CMAKE_CL_64)
    link_directories(${CMAKE_SOURCE_DIR}/third-party/glfw/lib/win32)
	link_directories(${CMAKE_SOURCE_DIR}/third-party/assimp/lib/win32)
	link_directories(${CMAKE_SOURCE_DIR}/third-party/opencv/lib/win32)
endif(CMAKE_CL_64)



# 添加src文件
file(GLOB_RECURSE SRC_GUI ${CMAKE_SOURCE_DIR}/src/*.cpp ${CMAKE_SOURCE_DIR}/src/*.h)
list(REMOVE_ITEM SRC_GUI ${CMAKE_SOURCE_DIR}/src/misc/freetype/*)
#file(GLOB_RECURSE SRC_THIRD_GLAD ${CMAKE_SOURCE_DIR}/third-party/glad/*.cpp ${CMAKE_SOURCE_DIR}/third-party/glad/*.h)
file(GLOB_RECURSE SRC_THIRD_STB ${CMAKE_SOURCE_DIR}/third-party/stb/*.h)

# 添加可执行文件
add_library(libsweety SHARED
    ${SRC_MAIN} 
	${SRC_GUI} 
	#${SRC_THIRD_GLAD}
	${SRC_THIRD_STB} 
    )

# 设置输出目录
set_target_properties(libsweety PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin)
set_target_properties(libsweety PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)


# 添加链接库
target_link_libraries(
    libsweety
	opengl32.lib
    glfw3.lib
	assimp.lib
	opencv_world455d.lib
	opencv_ts455.lib
    )